package com.richrail.console.commands;

import com.richrail.model.entities.DepotStorage;

public class GetNumSeatsCommand
{
	private DepotStorage depotStorage;
	
	public void setDepotStorage(DepotStorage depotStorage)
	{
		this.depotStorage = depotStorage;
	}
	
	public String execute(String type, String name)
	{
		int seatCount;
		
		if (type.equals("train"))
		{
			seatCount = depotStorage.getTrainSeatCount(name);
		}
		else
		{
			seatCount = depotStorage.getWagonSeatCount(name);
		}
		
		if (seatCount != -1)
		{
			return "number of seats in " + type + " " + name + ": " + seatCount;
		}
		else
		{
			return type + " " + name + " does not exists";
		}
	}
}
